package com.orphan.marketBack.service.impl;

import com.orphan.marketBack.dao.OrderReturnMapper;
import com.orphan.marketBack.dao.ReturnOrderMapper;
import com.orphan.marketBack.dto.OrderReturnDto;
import com.orphan.marketBack.service.OrderReturnService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service("OrderReturnServiceImpl")
public class OrderReturnServiceImpl implements OrderReturnService {
    private int a = 0;
    @Autowired
    OrderReturnMapper orderReturnMapper;
    
    @Autowired
    ReturnOrderMapper returnOrderMapper;
    @Autowired
    RabbitTemplate rabbitTemplate;
    @Override
    public List<OrderReturnDto> selectOrderReturn() {

        return orderReturnMapper.selectOrderReturn();
    }

    @Override
    public List<OrderReturnDto> selectOrderReturnByGoodsName(OrderReturnDto orderReturnDto) {
        List<OrderReturnDto> orderReturnDtos = orderReturnMapper.selectOrderReturnByGoodsName(orderReturnDto);

        return orderReturnDtos;

    }

//    @RabbitListener(queues = "returnsDetailQueue")
//    public void getOrderReturnMQ(ReturnsDetailsDto returnsDetailsDto){
//        OrderReturn orderReturn = new OrderReturn();
//
//        orderReturn.setOrderNo(returnsDetailsDto.getOrderNo());
//        orderReturn.setReturnsNo(returnsDetailsDto.getReturnsNo());
//        orderReturn.setGoodsName(returnsDetailsDto.getGoodsName());
//        orderReturn.setGoodsCount(returnsDetailsDto.getGoodsCount());
//        orderReturn.setGoodsOrderStatus(returnsDetailsDto.getGoodsOrderStatus());
//        orderReturn.setGoodsPrice(returnsDetailsDto.getGoodsPrice());
//        orderReturn.setReturnsTime(returnsDetailsDto.getReturnsTime());
//        orderReturn.setGoodsType(returnsDetailsDto.getGoodsType());
//
//        int insert = returnOrderMapper.insert(orderReturn);
//        if(insert > 0){
//            rabbitTemplate.convertAndSend("queueOrderReturn","orderReturn",orderReturn);
//        }
//
//    }

}
